//
//  ZZViewUtil.swift
//  QMXK
//
//  Created by jenkin on 2018/12/5.
//  Copyright © 2018年 jenkin. All rights reserved.
//

import UIKit

var testDataStr:String = "testDataStr"

class ZZViewUtil: NSObject {
    
    static let shareViewUtil:ZZViewUtil = ZZViewUtil.init()
    
    func createLabel(textAlign : NSTextAlignment, text : String, font : UIFont, color: UIColor, autoLine : Bool) -> UILabel{
        let label:UILabel = UILabel.init()
        label.textAlignment = textAlign
        label.text = text
        label.font = font
        if autoLine == true{
            label.numberOfLines = 0
        }
        return label
    }
    
    func createLineView() -> UIView{
        let lineView:UIView = UIView.init()
        lineView.backgroundColor = ColorConst.shareColorConst.lineColor()
        return lineView
    }
    
    func createImageView(contentmodel:UIView.ContentMode, name:String) -> UIImageView{
        let img:UIImageView = UIImageView.init()
        img.contentMode = contentmodel
        if name.count > 0{
            img.image = UIImage.init(named: name)
        }
        return img
    }
    
    func createImageView(contentmodel:UIView.ContentMode, name:String, corner:CGFloat) -> UIImageView{
        
        let img:UIImageView = ZZViewUtil.shareViewUtil.createImageView(contentmodel: contentmodel, name: name)
        img.layer.masksToBounds = true
        img.layer.cornerRadius = corner
        
        return img
    }
    
    func createButton(title:String, selectTitle:String, titleColor:UIColor) -> UIButton{
        let btn:UIButton = UIButton.init()
        btn.setTitle(title, for: UIControl.State.normal)
        btn.setTitle(selectTitle, for: UIControl.State.selected)
        btn.setTitleColor(titleColor, for: UIControl.State.normal)
        return btn;
    }
}
